package service.impl;

import dao.DepartmentDao;
import pojo.Department;
import service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService {

    @Autowired
    private DepartmentDao departmentDao;

    @Override
    public List<Department> findAll() {
        return departmentDao.findAll();
    }

    @Override
    public Department findById(Integer id) {
        return departmentDao.findById(id);
    }

    @Override
    public List<Department> findByLevel(Integer level) {
        return departmentDao.findByLevel(level);
    }

    @Override
    public List<Department> findByParentId(Integer parentId) {
        return departmentDao.findByParentId(parentId);
    }

    @Override
    public boolean save(Department department) {
        int result = departmentDao.insert(department);
        return result > 0;
    }

    @Override
    public boolean update(Department department) {
        int result = departmentDao.update(department);
        return result > 0;
    }

    @Override
    public boolean delete(Integer id) {
        int result = departmentDao.delete(id);
        return result > 0;
    }

    @Override
    public int updateDepartment(Department department) {
        return 0;
    }

    @Override
    public int addDepartment(Department department) {
        return 0;
    }

    @Override
    public int deleteDepartment(int departmentId) {
        return 0;
    }
}